package com.os.opencv.java.chapter6;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class MedianBlur {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //读取图像并在屏幕上显示
        Mat src = Imgcodecs.imread("/Users/matt/Pictures/peppersalt.jpg");
        HighGui.imshow("peppersalt", src);
        HighGui.waitKey(0);

        //对图像进行中值滤波并在屏幕上显示
        Mat dst = new Mat();
        Imgproc.medianBlur(src, dst, 5);
        HighGui.imshow("medianBlur", dst);
        HighGui.waitKey(0);

        //对图像进行均值滤波并在屏幕上显示
        Imgproc.blur(src, dst, new Size(5,5));
        HighGui.imshow("blur", dst);
        HighGui.waitKey(0);

        //对图像进行高斯滤波并在屏幕上显示
        Imgproc.GaussianBlur(src, dst, new Size(5,5), 10, 10);
        HighGui.imshow("gaussian blur", dst);
        HighGui.waitKey(0);

        System.exit(0);
    }
}
